module dogre.colourvalue;

import dogre.internals.utils;

extern(C)
{
    void* getColourValue(float, float, float, float);
    float* get_ColourValueRptr(void*);
    float* get_ColourValueGptr(void*);
    float* get_ColourValueBptr(void*);
    float* get_ColourValueAptr(void*);
}

class ColourValue
{
    void* p;
    
    private float* pr, pg, pb, pa;
    this(float red = 1.0, float green = 1.0, float blue = 1.0, float alpha = 1.0)
    {
        p = getColourValue(red, green, blue, alpha);
        _getPtrs();
    }
    
    this(void* ptr)
    {
        p = ptr;
        assert(p);  //Make sure its not null
        _getPtrs();
    }
    
    private void _getPtrs()
    {
        pr = get_ColourValueRptr(p);
        pg = get_ColourValueGptr(p);
        pb = get_ColourValueBptr(p);
        pa = get_ColourValueAptr(p);
    }
    @property float r()
    {
        return *pr;
    }
    @property void r(float value)
    {
        *pr = value;
    }
    @property float g()
    {
        return *pg;
    }
    @property void g(float value)
    {
        *pg = value;
    }
    @property float b()
    {
        return *pb;
    }
    @property void b(float value)
    {
        *pb = value;
    }
    @property float a()
    {
        return *pa;
    }
    @property void a(float value)
    {
        *pa = value;
    }
}
